[HEADER]
	VERSION		00.00.00.00
	DESCRIPTION Lattice Example
	COPYRIGHT	Imagination Technologies Ltd.
[/HEADER]

[TEXTURES]
[/TEXTURES]

[VERTEXSHADER]
	NAME myVertShader
	[GLSL_CODE]
		attribute vec4	myVertex;
		attribute vec3	myNormal;
		attribute vec2	myUV;
		uniform mat4	myMVPMatrix;
		uniform mat3	myModelViewIT;

		const mediump vec3  LightDirection = vec3(0.0, 0.5, 0.5);
		const mediump vec3  SurfaceColor = vec3(0.9, 0.7, 0.25);
		const mediump vec4	myMaterial = vec4(0.5,0.5,5.0,0.8);

		varying mediump vec3  Color;
		varying mediump vec2  texCoord;

		void main(void)
		{
			// Passthrough UV cordinates
			texCoord  = myUV.st;
			
			// transform position
			gl_Position    = myMVPMatrix * myVertex;
			
			// transform normal
			mediump vec3 tnorm   = normalize(myModelViewIT * myNormal);
			
			// Calsulate diffuse lighting
			mediump float DiffuseIntensity = dot(LightDirection, tnorm) * 0.5 + 0.5;
			
			mediump float SpecularIntensity = (DiffuseIntensity-myMaterial.w)* myMaterial.z;
			SpecularIntensity = max(SpecularIntensity,0.0);

			// Set the colour for the fragment shader
			Color = (SurfaceColor * DiffuseIntensity) + SpecularIntensity;
		}
	[/GLSL_CODE]
[/VERTEXSHADER]

[FRAGMENTSHADER]
	NAME myFragShader
	[GLSL_CODE]
		varying mediump vec3  Color;
		varying mediump vec2  texCoord;

		const mediump vec2  Scale = vec2(10, 10);
		const mediump vec2  Threshold = vec2(0.13, 0.13);


		void main (void)
		{
			mediump float ss = fract(texCoord.s * Scale.s);
			mediump float tt = fract(texCoord.t * Scale.t);

			if ((ss > Threshold.s) && (tt > Threshold.t)) discard;

			
			gl_FragColor = vec4 (Color, 1.0);
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]

[EFFECT]
	NAME myEffect

	ATTRIBUTE	myVertex			POSITION
	ATTRIBUTE	myNormal			NORMAL
	ATTRIBUTE	myUV				UV
	UNIFORM		myMVPMatrix			WORLDVIEWPROJECTION
	UNIFORM		myModelViewIT		WORLDVIEWIT

	VERTEXSHADER myVertShader
	FRAGMENTSHADER myFragShader
[/EFFECT]
